﻿
@{
    ViewBag.Title = "Login";
}

<h2>Login</h2>
<table>
    <tr>
        <td>账号:</td>
        <td>
            <input type="text" value="SanYing" id="num" />
        </td>
    </tr>
    <tr>
        <td>密码:</td>
        <td>
            <input type="password" value="123456" id="pwd" />
        </td>
    </tr>
    <tr>
        <td>密码:</td>
        <td>
            <button onclick="login()">登录</button>
        </td>
    </tr>
</table>
<script src="~/Scripts/jquery-3.4.1.js"></script>
<script>
    function login() {
        console.log("null");
        $.post("/MyHome/Login", { num: $("#num").val(), pwd: $("#pwd").val() }, function (data) {
            switch (data) {
                case 0:
                    alert("账号密码错误");
                    break;
                case 1:
                    alert("登录成功");
                    location = "/MyHome/Index";
                    break;
                case 2:
                    console.log("null");
                    break;
            }
        })
    }
</script>

